import 'package:nyh_motorcade_app/entity/card_details_entity.dart';
import 'package:nyh_motorcade_app/entity/driver_info_entity.dart';

cardDetailsEntityFromJson(CardDetailsEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'].toString();
	}
	if (json['createTime'] != null) {
		data.createTime = json['createTime'].toString();
	}
	if (json['createUser'] != null) {
		data.createUser = json['createUser'].toString();
	}
	if (json['createUserId'] != null) {
		data.createUserId = json['createUserId'].toString();
	}
	if (json['updateTime'] != null) {
		data.updateTime = json['updateTime'].toString();
	}
	if (json['updateUser'] != null) {
		data.updateUser = json['updateUser'].toString();
	}
	if (json['updateUserId'] != null) {
		data.updateUserId = json['updateUserId'].toString();
	}
	if (json['createEmpno'] != null) {
		data.createEmpno = json['createEmpno'];
	}
	if (json['updateEmpno'] != null) {
		data.updateEmpno = json['updateEmpno'];
	}
	if (json['headquarterGroupId'] != null) {
		data.headquarterGroupId = json['headquarterGroupId'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['cardNumber'] != null) {
		data.cardNumber = json['cardNumber'].toString();
	}
	if (json['motorcadeId'] != null) {
		data.motorcadeId = json['motorcadeId'].toString();
	}
	if (json['motorcadeName'] != null) {
		data.motorcadeName = json['motorcadeName'].toString();
	}
	if (json['cardType'] != null) {
		data.cardType = json['cardType'].toString();
	}
	if (json['cardTypeName'] != null) {
		data.cardTypeName = json['cardTypeName'].toString();
	}
	if (json['energyType'] != null) {
		data.energyType = json['energyType'].toString();
	}
	if (json['energyTypeName'] != null) {
		data.energyTypeName = json['energyTypeName'].toString();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['remark'] != null) {
		data.remark = json['remark'].toString();
	}
	if (json['driverInfo'] != null) {
		data.driverInfo = (json['driverInfo'] as List).map((v) => DriverInfoItem().fromJson(v)).toList();
	}
	if (json['cardBalance'] != null) {
		data.cardBalance = json['cardBalance'] is String
				? double.tryParse(json['cardBalance'])
				: json['cardBalance'].toDouble();
	}
	return data;
}

Map<String, dynamic> cardDetailsEntityToJson(CardDetailsEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['createTime'] = entity.createTime;
	data['createUser'] = entity.createUser;
	data['createUserId'] = entity.createUserId;
	data['updateTime'] = entity.updateTime;
	data['updateUser'] = entity.updateUser;
	data['updateUserId'] = entity.updateUserId;
	data['createEmpno'] = entity.createEmpno;
	data['updateEmpno'] = entity.updateEmpno;
	data['headquarterGroupId'] = entity.headquarterGroupId;
	data['name'] = entity.name;
	data['cardNumber'] = entity.cardNumber;
	data['motorcadeId'] = entity.motorcadeId;
	data['motorcadeName'] = entity.motorcadeName;
	data['cardType'] = entity.cardType;
	data['cardTypeName'] = entity.cardTypeName;
	data['energyType'] = entity.energyType;
	data['energyTypeName'] = entity.energyTypeName;
	data['status'] = entity.status;
	data['remark'] = entity.remark;
	data['driverInfo'] =  entity.driverInfo?.map((v) => v.toJson())?.toList();
	data['cardBalance'] = entity.cardBalance;
	return data;
}